package com.meiwenhui.callu.adapter;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;

import com.meiwenhui.callu.R;

public class ContactCursorAdapter extends CursorAdapter {

	private final LayoutInflater mInflater;

	public ContactCursorAdapter(Context context, Cursor c) {
		super(context, c);
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		TextView txtContactName = (TextView) view.findViewById(R.id.txt_contact_name);
		TextView txtContactNumber = (TextView) view.findViewById(R.id.txt_contact_number);

		String mName = cursor.getString(cursor.getColumnIndex("mName"));
		String mPhoneNumber = cursor.getString(cursor.getColumnIndex("mPhoneNumber"));

		txtContactName.setText(mName);
		txtContactNumber.setText(mPhoneNumber);
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		return mInflater.inflate(R.layout.contact_list_item, parent, false);
	}

}
